home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_windowmaker.idb / usr / freeware / include / WINGsP.h.z / WINGsP.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  9.4 KB  |  431 lines

  1. #ifndef _WINGSP_H_
  2. #define _WINGSP_H_
  3.  
  4.  
  5. #include <X11/Xlib.h>
  6. #include <X11/Xutil.h>
  7.  
  8.  
  9. #include "WINGs.h"
  10. #include "WUtil.h"
  11.  
  12. #if WINGS_H_VERSION < 990222
  13. #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
  14. #endif
  15.  
  16. #include <assert.h>
  17.  
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <stdio.h>
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25.  
  26. #define DOUBLE_BUFFER
  27.  
  28.  
  29.  
  30. #define WC_UserWidget    128
  31.  
  32.  
  33.  
  34. #define SCROLLER_WIDTH     20
  35.  
  36. /* internal messages */
  37. #define WM_UPDATE_COLORWELL    130
  38.  
  39.  
  40. #define WM_USER_MESSAGE    1024
  41.  
  42.  
  43. #define SETUP_INTERNAL_MESSAGE(event, scrPtr) \
  44.         event.xclient.type=ClientMessage;\
  45.         event.xclient.display=scrPtr->display;\
  46.         event.xclient.send_event=False;\
  47.         event.xclient.serial=0;\
  48.         event.xclient.format=32;\
  49.         event.xclient.message_type=scrPtr->internalMessage;
  50.  
  51.  
  52. typedef struct W_Font {
  53.     struct W_Screen *screen;
  54.  
  55.     union {
  56.     XFontSet set;
  57.     XFontStruct *normal;
  58.     } font;
  59.     short height;
  60.     short y;
  61.     short refCount;
  62.     char *name;
  63.     unsigned int notFontSet:1;
  64. } W_Font;
  65.  
  66.  
  67. typedef struct W_Pixmap {
  68.     struct W_Screen *screen;
  69.     Pixmap pixmap;
  70.     Pixmap mask;
  71.     unsigned short width;
  72.     unsigned short height;
  73.     short depth;
  74.     short refCount;
  75. } W_Pixmap;
  76.  
  77.  
  78. typedef struct W_Color {
  79.     struct W_Screen *screen;
  80.  
  81.     XColor color;
  82.     short refCount;
  83.     GC gc;
  84.     struct {
  85.     unsigned int exact:1;
  86.     } flags;
  87. } W_Color;
  88.  
  89.  
  90. typedef struct W_FocusInfo {
  91.     struct W_View *toplevel;
  92.     struct W_View *focused;           /* view that has the focus in this toplevel */
  93.     struct W_FocusInfo *next;
  94. } W_FocusInfo;
  95.  
  96. typedef struct W_Screen {
  97.     Display *display;
  98.     int screen;
  99.     int depth;
  100.  
  101.     Colormap colormap;
  102.     
  103.     Visual *visual;
  104.     
  105.     Time lastEventTime;
  106.     
  107.     Window rootWin;
  108.  
  109.     struct W_View *rootView;
  110.     
  111.     RContext *rcontext;
  112.  
  113.     /* application related */
  114.  
  115.     W_FocusInfo *focusInfo;
  116.  
  117.     struct W_Pixmap *applicationIcon;
  118.  
  119.     struct W_Window *windowList;       /* list of windows in the app */
  120.  
  121.     Window groupLeader;               /* the leader of the application */
  122.                            /* also used for other things */
  123.  
  124.     struct W_SelectionHandlers *selectionHandlerList;
  125.  
  126.     struct {
  127.     unsigned int hasAppIcon:1;
  128.     unsigned int simpleApplication:1;
  129.     } aflags;
  130.  
  131.     WMOpenPanel *sharedOpenPanel;
  132.     WMSavePanel *sharedSavePanel;
  133.  
  134.     struct W_FontPanel *sharedFontPanel;
  135.  
  136.     struct W_ColorPanel *sharedColorPanel;
  137.     
  138.     /* colors */
  139.     W_Color *white;
  140.     W_Color *black;
  141.     W_Color *gray;
  142.     W_Color *darkGray;
  143.  
  144.     GC stippleGC;
  145.     
  146.     GC copyGC;
  147.     GC clipGC;
  148.     
  149.     GC monoGC;                   /* GC for 1bpp visuals */
  150.     
  151.     GC xorGC;
  152.  
  153.     GC ixorGC;                   /* IncludeInferiors XOR */
  154.  
  155.     GC textFieldGC;
  156.     
  157.     W_Font *normalFont;
  158.  
  159.     W_Font *boldFont;
  160.  
  161.     WMHashTable *fontCache;
  162.  
  163.     struct W_Pixmap *checkButtonImageOn;
  164.     struct W_Pixmap *checkButtonImageOff;
  165.     
  166.     struct W_Pixmap *radioButtonImageOn;
  167.     struct W_Pixmap *radioButtonImageOff;
  168.  
  169.     struct W_Pixmap *buttonArrow;
  170.     struct W_Pixmap *pushedButtonArrow;
  171.  
  172.     struct W_Pixmap *scrollerDimple;
  173.     
  174.     struct W_Pixmap *upArrow;
  175.     struct W_Pixmap *downArrow;
  176.     struct W_Pixmap *leftArrow;
  177.     struct W_Pixmap *rightArrow;
  178.     
  179.     struct W_Pixmap *hiUpArrow;
  180.     struct W_Pixmap *hiDownArrow;
  181.     struct W_Pixmap *hiLeftArrow;
  182.     struct W_Pixmap *hiRightArrow;
  183.  
  184.     struct W_Pixmap *pullDownIndicator;
  185.     struct W_Pixmap *popUpIndicator;
  186.  
  187.     struct W_Pixmap *checkMark;
  188.  
  189.     struct W_Pixmap *homeIcon;
  190.     struct W_Pixmap *altHomeIcon;
  191.  
  192.     struct W_Pixmap *magnifyIcon;
  193.     struct W_Pixmap *altMagnifyIcon;
  194.     struct W_Pixmap *wheelIcon;
  195.     struct W_Pixmap *grayIcon;
  196.     struct W_Pixmap *rgbIcon;
  197.     struct W_Pixmap *cmykIcon;
  198.     struct W_Pixmap *hsbIcon;
  199.     struct W_Pixmap *customPaletteIcon;
  200.     struct W_Pixmap *colorListIcon;
  201.     
  202.     struct W_Pixmap *defaultObjectIcon;
  203.     
  204.     Cursor defaultCursor;
  205.     
  206.     Cursor textCursor;
  207.  
  208.     Atom internalMessage;           /* for ClientMessage */
  209.     
  210.     Atom attribsAtom;               /* GNUstepWindowAttributes */
  211.     
  212.     Atom deleteWindowAtom;           /* WM_DELETE_WINDOW */
  213.     
  214.     Atom protocolsAtom;               /* _XA_WM_PROTOCOLS */
  215.     
  216.     Atom clipboardAtom;               /* CLIPBOARD */
  217.  
  218.  
  219.     /* stuff for detecting double-clicks */
  220.     Time lastClickTime;               /* time of last mousedown event */
  221.     Window lastClickWindow;           /* window of the last mousedown */
  222.  
  223.     struct W_View *modalView;
  224.     unsigned modal:1;
  225.     unsigned ignoreNextDoubleClick:1;
  226. } W_Screen;
  227.  
  228.  
  229.  
  230. typedef struct W_View {
  231.     struct W_Screen *screen;
  232.  
  233.     WMWidget *self;               /* must point to the widget the
  234.                     * view belongs to */
  235.     
  236.     Window window;
  237.  
  238.     WMSize size;
  239.  
  240.     WMPoint pos;
  241.     
  242.     struct W_View *nextFocusChain;     /* next/prev in focus chain */
  243.     struct W_View *prevFocusChain;
  244.         
  245.     struct W_View *parent;           /* parent WMView */
  246.     
  247.     struct W_View *childrenList;       /* first in list of child windows */
  248.     
  249.     struct W_View *nextSister;           /* next on parent's children list */
  250.     
  251.     struct W_EventHandler *handlerList;/* list of event handlers for this window */
  252.  
  253.     unsigned long attribFlags;
  254.     XSetWindowAttributes attribs;
  255.     
  256.     void *hangedData;               /* data holder for user program */
  257. #if 0
  258.     struct W_DragSourceProcs *dragSourceProcs;
  259.     struct W_DragDestinationProcs *dragDestinationProcs;
  260.     int helpContext;
  261. #endif
  262.  
  263.     struct {
  264.     unsigned int realized:1;
  265.     unsigned int mapped:1;
  266.     unsigned int parentDying:1;
  267.     unsigned int dying:1;           /* the view is being destroyed */
  268.     unsigned int topLevel:1;       /* is a top level window */
  269.     unsigned int root:1;           /* is the root window */
  270.     unsigned int mapWhenRealized:1;/* map the view when it's realized */
  271.     unsigned int alreadyDead:1;    /* view was freed */
  272.  
  273.     unsigned int dontCompressMotion:1;   /* motion notify event compress */
  274.     unsigned int notifySizeChanged:1;
  275.     unsigned int dontCompressExpose:1;   /* will compress all expose
  276.                           events into one */
  277.     /* toplevel only */
  278.     unsigned int worksWhenModal:1;
  279.     unsigned int pendingRelease1:1;
  280.     unsigned int pendingRelease2:1;
  281.     unsigned int pendingRelease3:1;
  282.     unsigned int pendingRelease4:1;
  283.     unsigned int pendingRelease5:1;
  284.     } flags;
  285.     
  286.     int refCount;
  287. } W_View;
  288.  
  289.  
  290. typedef struct W_EventHandler {
  291.     unsigned long eventMask;
  292.     
  293.     WMEventProc *proc;
  294.     
  295.     void *clientData;
  296.     
  297.     struct W_EventHandler *nextHandler;
  298. } W_EventHandler;
  299.  
  300.  
  301.  
  302. typedef struct W_ViewProcedureTable {
  303.     void (*setBackgroundColor)(WMWidget*, WMColor *color);
  304.     void (*resize)(WMWidget*, unsigned int, unsigned int);
  305.     void (*move)(WMWidget*, int, int);
  306. } W_ViewProcedureTable;
  307.  
  308.  
  309.  
  310. typedef struct _WINGsConfiguration {
  311.     char *systemFont;
  312.     char *boldSystemFont;
  313.     unsigned doubleClickDelay;
  314. } _WINGsConfiguration;
  315.  
  316. _WINGsConfiguration WINGsConfiguration;
  317.  
  318.  
  319.  
  320. #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
  321.  
  322.  
  323. #define W_CLASS(widget)      (((W_WidgetType*)(widget))->widgetClass)
  324. #define W_VIEW(widget)       (((W_WidgetType*)(widget))->view)
  325.  
  326. #define W_VIEW_REALIZED(view)    (view)->flags.realized
  327. #define W_VIEW_MAPPED(view)    (view)->flags.mapped
  328.  
  329. #define W_PIXEL(c)        (c)->color.pixel
  330.  
  331. #define W_FONTID(f)        (f)->font->fid
  332.  
  333. #define W_DRAWABLE(scr)        (scr)->rcontext->drawable
  334.  
  335.  
  336.  
  337. W_View *W_GetViewForXWindow(Display *display, Window window);
  338.  
  339. W_View *W_CreateView(W_View *parent);
  340.  
  341. W_View *W_CreateTopView(W_Screen *screen);
  342.  
  343.  
  344. W_View *W_CreateRootView(W_Screen *screen);
  345.  
  346. void W_DestroyView(W_View *view);
  347.  
  348. void W_RealizeView(W_View *view);
  349.  
  350. void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
  351.  
  352. void W_MapView(W_View *view);
  353.  
  354. void W_MapSubviews(W_View *view);
  355.  
  356. void W_UnmapSubviews(W_View *view);
  357.  
  358. W_View *W_TopLevelOfView(W_View *view);
  359.  
  360. void W_UnmapView(W_View *view);
  361.  
  362. void W_MoveView(W_View *view, int x, int y);
  363.  
  364. void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
  365.  
  366. void W_SetViewBackgroundColor(W_View *view, WMColor *color);
  367.  
  368. void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
  369.           unsigned int height, WMReliefType relief);
  370.  
  371.  
  372. void W_CleanUpEvents(W_View *view);
  373.  
  374. void W_CallDestroyHandlers(W_View *view);
  375.  
  376. void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
  377.              WMReliefType relief, char *text,
  378.              WMAlignment alignment, W_Pixmap *image, 
  379.              WMImagePosition position, GC backGC, int ofs);
  380.  
  381. void W_PaintText(W_View *view, Drawable d, WMFont *font,  int x, int y,
  382.          int width, WMAlignment alignment, GC gc,
  383.          int wrap, char *text, int length);
  384.  
  385. int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
  386.  
  387.  
  388. int W_TextWidth(WMFont *font, char *text, int length);
  389.  
  390.  
  391. void W_BroadcastMessage(W_View *targetParent, XEvent *event);
  392.  
  393. void W_DispatchMessage(W_View *target, XEvent *event);
  394.  
  395. Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
  396.  
  397. void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
  398.  
  399. W_View *W_FocusedViewOfToplevel(W_View *view);
  400.  
  401. void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
  402.  
  403. void W_ReleaseView(WMView *view);
  404.  
  405. WMView *W_RetainView(WMView *view);
  406.  
  407. void W_InitApplication(WMScreen *scr);
  408.  
  409. void W_InitNotificationCenter(void);
  410.  
  411. W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
  412.  
  413. void W_RedisplayView(WMView *view);
  414.  
  415. Bool W_ApplicationInitialized(void);
  416.  
  417. char *W_GetTextSelection(WMScreen *scr, Atom selection);
  418.  
  419. void W_HandleSelectionEvent(XEvent *event);
  420.  
  421. #ifdef __cplusplus
  422. }
  423. #endif /* __cplusplus */
  424.  
  425. #endif /* _WINGSP_H_ */
  426.  
  427. void W_FlushASAPNotificationQueue();
  428.  
  429. void W_FlushIdleNotificationQueue();
  430.  
  431.